#!/usr/sbin/rsct/perl5/bin/perl
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
#  
#  
# Licensed Materials - Property of IBM 
#  
# (C) COPYRIGHT International Business Machines Corp. 2000,2004 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
#
# @(#)29   1.5         src/rsct/cfg_access/gpfs/ct_write_machines_lst.perl, cfg.access, rsct_rzauh, rzauh0431a 1/27/03 18:56:57
#
# Usage: ct_write_machines_lst  <filename>
#


# Get the arguments...
if ($#ARGV < 0) {
    print STDERR "#No output file name\n";
    exit 1;
}

my $filename = shift @ARGV;            # user specified resource

($dir,$progname) = $0 =~ /(.*\/)?(.*)/; # get basename of $0


#-------- functions -----------------------------------
# print_dbgmsg(list)
sub print_dbgmsg
{
  my @args = @_;
  if(!defined($ccal_log_inited)) {
        my $outfile = $ENV{"HA_CCAL_LOG"};
        $ccal_log_inited = 0;
        if(defined($outfile) && open(LOGOUT, ">>$outfile")) {
            $ccal_log_inited = 1;
            select LOGOUT;
            $| = 1; # unbuffered
            select STDOUT;
        }
  }
  if($ccal_log_inited) {
        my $dstr = scalar(localtime);
        my $msg = "$dstr $progname: " . join(" ", @args);
        print LOGOUT $msg, "\n" ;
  }
}

sub print_errmsg
{
   &print_dbgmsg(@_);
   print STDERR "# $progname: ", join(" ", @_), "\n";
}
#-----------------------------------------------------

# return codes:
#   0 if successful
#   1 if there is an error
#   2 if <ct_write_machines.lst> not supported

$MMHA="/usr/lpp/mmfs/bin/mmha";
$MMHACMD="${MMHA} haPutMachineslst $filename"; 
&print_dbgmsg("$MMHACMD");
exec "${MMHACMD}";
exit 1;
